;
; Hello world for Linux
;
; Author: Renê de Souza Pinto
; Date..: Feb, 2009
;
; To compile: nasm hello.asm -f elf
; To link:    ld hello.o -o hello
;

[Bits 32]

[global _start]

%define SYS_WRITE 0x04 ; The syscall number for sys_write
%define SYS_EXIT  0x01 ; The syscall number for sys_exit
%define STDOUT    0x01 ; The standard output

section .text

_start:
	; Print message
	; sys_write arguments
	mov edx, msglen
	mov ecx, message
	mov ebx, STDOUT

	; Call Linux syscalls interrupt
	mov eax, SYS_WRITE
	int 0x80

	; Exit program
	; Push syscall arguments into the stack
	mov ebx,0x00 		; Return code
	push ebx

	; Call Linux syscalls interrupt
	mov eax,SYS_EXIT
	int 0x80

section .data

	message db 'Hello World!',13,10,0
	msglen  equ $-message

